
/*** Create consistent years of education variable ***/
/*** From 1992 on, use Table 5 from Park (1994) ***/

gen yearsch=.
replace yearsch=gradeat   if (year>=1979 & year<=1991) & gradecp==1
replace yearsch=gradeat-1 if (year>=1979 & year<=1991) & gradecp==2
replace yearsch=0         if (year>=1979 & year<=1991) & gradeat==0

/*** Create variable educ99 (see IPUMS-CPS for description) ***/
gen educ99=.

replace educ99=1  if (year>=1992 & year<=2020) & grade92==31
replace educ99=4  if (year>=1992 & year<=2020) & grade92==32
replace educ99=5  if (year>=1992 & year<=2020) & grade92==33 | grade92==34
forval x=6/17{
	replace educ99=`x'  if (year>=1992 & year<=2020) & grade92==`x'+29
}


/*** Black Female ***/
replace yearsch= 0     if black==1 & female==1 & educ99<=3
replace yearsch= 2.9   if black==1 & female==1 & educ99==4
replace yearsch= 7.03  if black==1 & female==1 & educ99==5
replace yearsch= 9.05  if black==1 & female==1 & educ99==6
replace yearsch= 9.99  if black==1 & female==1 & educ99==7
replace yearsch= 10.85 if black==1 & female==1 & educ99==8
replace yearsch= 11.64 if black==1 & female==1 & educ99==9
replace yearsch= 12    if black==1 & female==1 & educ99==10
replace yearsch= 13.43 if black==1 & female==1 & educ99==11
replace yearsch= 14.33 if black==1 & female==1 & educ99==12
replace yearsch= 14.33 if black==1 & female==1 & educ99==13
replace yearsch= 16.04 if black==1 & female==1 & educ99==14
replace yearsch= 17.69 if black==1 & female==1 & educ99==15
replace yearsch= 17.4  if black==1 & female==1 & educ99==16
replace yearsch= 18    if black==1 & female==1 & educ99==17

/*** Black Male ***/
replace yearsch= 0.92  if black==1 & female==0 & educ99<=3
replace yearsch= 3.28  if black==1 & female==0 & educ99==4
replace yearsch= 7.04  if black==1 & female==0 & educ99==5
replace yearsch= 9.02  if black==1 & female==0 & educ99==6
replace yearsch= 9.91  if black==1 & female==0 & educ99==7
replace yearsch= 10.9  if black==1 & female==0 & educ99==8
replace yearsch= 11.41 if black==1 & female==0 & educ99==9
replace yearsch= 11.98 if black==1 & female==0 & educ99==10
replace yearsch= 13.57 if black==1 & female==0 & educ99==11
replace yearsch= 14.33 if black==1 & female==0 & educ99==12
replace yearsch= 14.33 if black==1 & female==0 & educ99==13
replace yearsch= 16.13 if black==1 & female==0 & educ99==14
replace yearsch= 17.51 if black==1 & female==0 & educ99==15
replace yearsch= 17.83 if black==1 & female==0 & educ99==16
replace yearsch= 18    if black==1 & female==0 & educ99==17

/*** Non-Black Female ***/
replace yearsch= 0.62  if black==0 & female==1 & educ99<=3
replace yearsch= 3.15  if black==0 & female==1 & educ99==4
replace yearsch= 7.23  if black==0 & female==1 & educ99==5
replace yearsch= 8.99  if black==0 & female==1 & educ99==6
replace yearsch= 9.95  if black==0 & female==1 & educ99==7
replace yearsch= 10.87 if black==0 & female==1 & educ99==8
replace yearsch= 11.73 if black==0 & female==1 & educ99==9
replace yearsch= 12.00 if black==0 & female==1 & educ99==10
replace yearsch= 13.35 if black==0 & female==1 & educ99==11
replace yearsch= 14.22 if black==0 & female==1 & educ99==12
replace yearsch= 14.22 if black==0 & female==1 & educ99==13
replace yearsch= 16.15 if black==0 & female==1 & educ99==14
replace yearsch= 17.64 if black==0 & female==1 & educ99==15
replace yearsch= 17    if black==0 & female==1 & educ99==16
replace yearsch= 17.76 if black==0 & female==1 & educ99==17

/*** Non-Black Male ***/
replace yearsch= 0.32  if black==0 & female==0 & educ99<=3
replace yearsch= 3.19  if black==0 & female==0 & educ99==4
replace yearsch= 7.24  if black==0 & female==0 & educ99==5
replace yearsch= 8.97  if black==0 & female==0 & educ99==6
replace yearsch= 9.92  if black==0 & female==0 & educ99==7
replace yearsch= 10.86 if black==0 & female==0 & educ99==8
replace yearsch= 11.58 if black==0 & female==0 & educ99==9
replace yearsch= 11.99 if black==0 & female==0 & educ99==10
replace yearsch= 13.48 if black==0 & female==0 & educ99==11
replace yearsch= 14.23 if black==0 & female==0 & educ99==12
replace yearsch= 14.23 if black==0 & female==0 & educ99==13
replace yearsch= 16.17 if black==0 & female==0 & educ99==14
replace yearsch= 17.68 if black==0 & female==0 & educ99==15
replace yearsch= 17.71 if black==0 & female==0 & educ99==16
replace yearsch= 17.83 if black==0 & female==0 & educ99==17

rename yearsch yearsch_1


/*** Create alternative years of education variable ***/
/*** From 1992 on, try to match Lemieux's (2006) numbers ***/

gen yearsch=.
replace yearsch=gradeat   if (year>=1979 & year<=1991) & gradecp==1
replace yearsch=gradeat-1 if (year>=1979 & year<=1991) & gradecp==2
replace yearsch=0         if (year>=1979 & year<=1991) & gradeat==0

replace yearsch=0  if (year>=1992 & year<=2020) & grade92==31
replace yearsch=3  if (year>=1992 & year<=2020) & grade92==32
replace yearsch=7  if (year>=1992 & year<=2020) & grade92==33 | grade92==34
replace yearsch=9  if (year>=1992 & year<=2020) & grade92==35
replace yearsch=10 if (year>=1992 & year<=2020) & grade92==36
replace yearsch=11 if (year>=1992 & year<=2020) & grade92==37
replace yearsch=12 if (year>=1992 & year<=2020) & grade92==38 | grade92==39
replace yearsch=13 if (year>=1992 & year<=2020) & grade92==40
replace yearsch=14 if (year>=1992 & year<=2020) & grade92==41 | grade92==42
replace yearsch=16 if (year>=1992 & year<=2020) & grade92==43
replace yearsch=18 if (year>=1992 & year<=2020) & grade92==44 | grade92==45 | grade92==46

rename yearsch yearsch_2

drop gradeat gradecp educ99
cap drop grade92
